package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.product.SkuInfo;
import com.atguigu.gmall.product.client.ProductFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;

/**
 * @author atguigu-mqx
 */
@Controller
public class CartController {

    @Autowired
    private ProductFeignClient productFeignClient;

    //  http://cart.gmall.com/addCart.html?skuId=22&skuNum=1&sourceType=query
    @GetMapping("addCart.html")
    public String addCart(Long skuId, Integer skuNum, Model model){
        //  获取skuInfo 对象
        SkuInfo skuInfo = productFeignClient.getSkuInfo(skuId);
        //  保存数据！
        model.addAttribute("skuInfo",skuInfo);
        model.addAttribute("skuNum",skuNum);
        return "cart/addCart";
    }

    //  查看购物车列表！
    @GetMapping("cart.html")
    public String cartList(){

        //  返回列表页面！
        return "cart/index";
    }

}
